package com.lu.model.helloworld;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

/**
 * Created by machine on 17-4-18.
 */
public class HelloWorldJPA {

    private static void saveMessage(){
        EntityManagerFactory factory= Persistence.createEntityManagerFactory("HelloWorldPU");


        EntityManager manager=factory.createEntityManager();
        EntityTransaction transaction= manager.getTransaction();
        transaction.begin();
        Message message=new Message();
        message.setText("hello world");
        manager.persist(message);
        transaction.commit();
    }

    public static void main(String args[]){
        saveMessage();
    }
}
